@use 'sass:list';
@use 'sass:meta';
@use '../uni.scss';

$spacing: (
  m: margin,
  p: padding
);

$location: (
  t: top,
  b: bottom,
  l: left,
  r: right,
  x: (
    left,
    right
  ),
  y: (
    top,
    bottom
  )
);

@for $i from 0 through 10 {
  @each $space-type, $space-property in $spacing {
    .#{$space-type}-#{$i} {
      #{$space-property}: $i * uni.$uni-spacing-size-base;
    }

    @each $loc-key, $loc-value in $location {
      .#{$space-type}#{$loc-key}-#{$i} {
        @if meta.type-of($loc-value) == 'list' {
          $v1: list.nth(
            $list: $loc-value,
            $n: 1
          );
          $v2: list.nth(
            $list: $loc-value,
            $n: 2
          );
          #{$space-property}-#{$v1}: $i * uni.$uni-spacing-size-base;
          #{$space-property}-#{$v2}: $i * uni.$uni-spacing-size-base;
        } @else {
          #{$space-property}-#{$loc-value}: $i * uni.$uni-spacing-size-base;
        }
      }
    }
  }
}

.m-auto {
  margin: auto;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.mt-0_5 {
  margin-top: uni.$uni-spacing-size-base * 0.5;
}

.mb-0_5 {
  margin-bottom: uni.$uni-spacing-size-base * 0.5;
}

.ml-0_5 {
  margin-left: uni.$uni-spacing-size-base * 0.5;
}

.mr-0_5 {
  margin-right: uni.$uni-spacing-size-base * 0.5;
}

.mt-1_5 {
  margin-top: uni.$uni-spacing-size-base * 1.5;
}

.mb-1_5 {
  margin-bottom: uni.$uni-spacing-size-base * 1.5;
}

.mr-1_5 {
  margin-right: uni.$uni-spacing-size-base * 1.5;
}

.mt-2_5 {
  margin-top: uni.$uni-spacing-size-base * 2.5;
}

.mb-2_5 {
  margin-bottom: uni.$uni-spacing-size-base * 2.5;
}

.ml-2_5 {
  margin-left: uni.$uni-spacing-size-base * 2.5;
}

.mr-2_5 {
  margin-right: uni.$uni-spacing-size-base * 2.5;
}

.pt-0_5 {
  padding-top: uni.$uni-spacing-size-base * 0.5;
}
